#ifndef __ConsumerThread_H__
#define __ConsumerThread_H__

#include "Thread.hpp"
#include "TaskQueue.hpp"

#include <unistd.h>

#include <iostream>
using std::cout;
using std::endl;


namespace wd
{


class ConsumerThread
: public Thread
{
public:
    ConsumerThread(TaskQueue & que)
    : _que(que)
    {}

    ~ConsumerThread() 
    {   cout << "~ConsumerThread()" << endl;    }

private:
    void run() override
    {
        int cnt = 20;
        while(cnt-- > 0) {
            int num = _que.pop();
            cout << "Cosume a num : " << num << endl;
            sleep(2);
        }
    }


private:
    TaskQueue & _que;
};


}//end of namespace wd


#endif

